import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:little_painter/utils/logger_utils.dart';

import '../../utils/dialog_utils.dart';
import '../../utils/router_utils.dart';
import '../main/controller/little_painter_controller.dart';

/// 测试页
class TestFunctionPage extends StatefulWidget {
  const TestFunctionPage({super.key});

  @override
  State<TestFunctionPage> createState() => _TestFunctionPageState();
}

class _TestFunctionPageState extends State<TestFunctionPage> {
  @override
  Widget build(BuildContext context) {
    LogUtils.d('TestFunctionPage');

    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            ElevatedButton(
              onPressed: () {
                RouterUtils.toTestFunction();
              },
              child: const Text('painter 参照'),
            ),
            ElevatedButton(
              onPressed: () {
                RouterUtils.toDrawingBoardPage();
              },
              child: const Text('画板'),
            ),
            GetBuilder<LittlePainterController>(
              builder: (controller) {
                return Text(
                  "计数器值为: ${controller.testCount}",
                  style: const TextStyle(color: Colors.green, fontSize: 30),
                );
              },
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          Get.find<LittlePainterController>().setTestCount();
        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
